<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            * {padding:0px;margin:0px;}
            .lbt {
                width: 500px;
                height: 180px;
                overflow: hidden;
                position: relative;
            }
            .lbt img {width: 100%;height:100%;}

            ul {
                position: absolute;
                list-style: none;
                overflow: hidden;
                bottom: 5px;
                right: 0px;
            }
            ul li {
                float: left;
                width: 20px;
                height: 20px;
                margin-right: 10px;
                line-height: 20px;
                text-align: center;
                background-color: black;
                color: #fff;
                border-radius: 50%;
            }
            ul li:hover {
                background-color: orange;
                color: #fff;
                cursor: pointer;
            }
        </style>
    </head>
    <body>
        <div class="lbt">
            <img src="./img/img1.jpg" alt="">
        
            <ul>
                <li>1</li>
                <li>2</li>
                <li>3</li>
                <li>4</li>
                <li>5</li>
                <li>6</li>
            </ul>
        </div>


        <script>
            var num = 1;
            function dsq() {
                timer = setInterval(function() {
                    var imgObj = document.querySelector('img')
                    console.log(num)
                    imgObj.src = "./img/img"+num+".jpg"
                    num++
                    if(num>6) num=1
                },1000)
            }
            dsq()

            var liObj = document.querySelectorAll('li')
            liObj.forEach(function(item,index) {
                item.onmouseover = function() {
                    clearInterval(timer);
                    document.querySelector('img').src = "./img/img"+(index+1)+".jpg"
                    num = index+1
                }
                item.onmouseout = function() {
                    dsq()
                }
            })
            
        </script>
    </body>
</html>